<template>
	<view >
		<view class="formModel">
		<view class="cu-form-group">
			<view class="title">员工名称</view>
			<input maxlength="5"  :placeholder="employeeList.staff_name" disabled="true" name="input"></input>
		</view>
		<view class="cu-form-group">
			<view class="title">员工电话</view>
			<input :placeholder="employeeList.staff_phone" disabled="true" maxlength="11" type="number"  name="input"></input>
		</view>
		<view class="cu-form-group">
			<view class="title">员工地址</view>
			<input  :placeholder="employeeList.staff_address" disabled="true" name="input"></input>
		</view>
		<view class="cu-form-group">
			<view class="title">申请时间</view>
			<input  :placeholder="employeeList.upd_statetime" disabled="true" name="input"></input>
		</view>
		<view class="cu-form-group">
			<view class="title">审核结果</view>
			<picker @change="PickerChange" :value="index1" :range="picker">
				<view class="picker">
					{{picker[index1]}}
				</view>
			</picker>
		</view>
	</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				index:'',
				employeeList:'',
				picker: ['请选择','通过','拒绝'],
				index1:0,
				state:''
			};
		},
		onReady() {
			this.getEmployee()
		},
		onLoad(option) {
			this.index = option.index
		},
		onNavigationBarButtonTap(){
			this.updState()
		},
		methods:{
			PickerChange(e) {
				this.index1 = e.detail.value;
				switch(e.detail.value){
					case 0:
					this.state = '';
					break;
					case 1:
					this.state = 1;
					break;
					case 2:
					this.state = 2;
				}
			},
			//提交审核状态
			updState(){
				if(!this.state){uni.showToast({
					icon:"none",
					title:"请选择审核结果"
				}); return;}
				uni.request({
					url:this.confige.webUrl+"/updState",
					header:{
						'X-Token':this.User.token
					},
					data:{
						staffId:this.employeeList.staff_id,
						state:this.state
					},
					success: (res) => {
						console.log(res);
						switch(res.data.code/100){
						case 2:
							uni.showModal({
								showCancel:false,
								title:"提示",
								content:"操作成功",
								success: (res) => {
								 if (res.confirm) {
									  uni.switchTab({
									  	url:"../set"
									  })
								 }        
								}
							})
							break;
						case 4:
						uni.showToast({
							icon:"none",
							title:res.data.message
						});
						uni.switchTab({
							url:"../set"
						})
						}
						
					}	
				})
			},
			//获取提交审核的员工名单
			getEmployee(){
			uni.request({
				url:this.confige.webUrl+"/listStaff",
				header:{
					'X-Token':this.User.token
				},
				data:{
					farmId:this.User.userInfo.farm_id,
				},
				success: (res) => {
					console.log(res);
					this.employeeList = res.data.result[this.index];
					console.log(this.employeeList)
				}	
			})
			},
		}
	}
</script>

<style lang="less" scoped>
@import "../../../common/colorui/main.css";
@import "../../../common/colorui/icon.css";
@import "../../../common/global.less";
page{ }
.RadioStyle{ 
	radio{
		margin-right: 10rpx;
		font-size: 30rpx;
		}
	}
.bottomModel{
margin-top: 50rpx;
// .butStyle{font-size: 30rpx; border-radius: 90rpx;width: 600rpx; height:80rpx;line-height: 80rpx;color:#FFFFFF; background-color:@maincolor;}
}
.formModel{
background-color:@backcolorthree;
border-bottom:2rpx solid #eaeaea;
.cu-form-group {
.title {min-width: calc(4em + 15px);}		
}
}

</style>
